package com.bosssoft.trainee.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bosssoft.trainee.mbg.mapper.PositionMapper;
import com.bosssoft.trainee.mbg.po.Position;
import com.bosssoft.trainee.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @Author: wuxin
 * @Project: rbac-SpringCloud
 * @Date: 2022/7/19
 * @Description:
 */
@Service
public class PositionServiceImp implements PositionService {
    @Autowired
    PositionMapper positionMapper;
    /**
     * 根据id批量获取Position
     *
     * @param ids
     * @return
     */
    @Override
    public List<Position> getPositions(List<Integer> ids) {
        if(ids==null||ids.isEmpty()){
            return null;
        }
        return positionMapper.selectBatchIds(new HashSet<>(ids));
    }

    /**
     * 获取所有Position
     *
     * @return
     */
    @Override
    public List<Position> getList() {
        Position example = new Position();
        //这里加入一些查询条件
        QueryWrapper<Position> queryWrapper = new QueryWrapper<>(example);
        return positionMapper.selectList(queryWrapper);
    }

    /**
     * 根据id删除Position
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Integer id) {
        return positionMapper.deleteById(id);
    }
}
